package com.example.android.chartapplication;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;

import com.example.android.chartapplication.Fragments.ChartCircleFragment;
import com.example.android.chartapplication.Fragments.ChartClockFragment;
import com.example.android.chartapplication.Fragments.ChartGestureFragment;
import com.example.android.chartapplication.Fragments.ChartLineFragment;
import com.example.android.chartapplication.Fragments.ChartRadarFragment;
import com.example.android.chartapplication.Fragments.ChartRectFragment;

import java.util.ArrayList;

public class MainActivity extends AppCompatActivity {

    ViewPager viewPager;
    ArrayList<Fragment> views = new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        viewPager = findViewById(R.id.viewPager);
        views.add(new ChartLineFragment());
        views.add(new ChartRectFragment());
        views.add(new ChartCircleFragment());
        views.add(new ChartGestureFragment());
        views.add(new ChartRadarFragment());
        views.add(new ChartClockFragment());

        viewPager.setAdapter(new FragmentPagerAdapter(getSupportFragmentManager()) {
            @Override
            public Fragment getItem(int position) {
                return views.get(position);
            }

            @Override
            public int getCount() {
                return views.size();
            }
        });
    }
}
